home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcoop.arc / TCOOP2.ARC / GRPHSCRN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  1.8 KB  |  61 lines

  1. // grphscrn.cpp:  A set of utilities used in the graphics 
  2. // applications in Chapters 13 and 14 
  3.  
  4. #include <stdio.h>
  5. #include "grphscrn.h"
  6.  
  7. Wso *FullScrn;
  8. MsgPkt StartMsg;
  9.  
  10. void Setup(int MouseOpt, int &GDriver, int &GMode,
  11.            char *DriverPath, unsigned Font)
  12. // Configures the graphics screen and mouse. Gmode is the graphics mode
  13. // to use. It should be one of QP's constants defined in MsGraph. MouseOpt
  14. // can be one of the options listed at the {ning of this file.
  15. // FontPath and FontStyle specify the font to be used in the application.
  16. // It also sets up the FullScrn object which will be the root window for
  17. // all windows on the screen. 
  18. {
  19.   int ErrCode;
  20.  
  21.   initgraph(&GDriver,&GMode,DriverPath);
  22.   ErrCode = graphresult();
  23.   if (ErrCode != grOk) {
  24.     printf("Graphics error: %s",grapherrormsg(ErrCode));
  25.     exit(1);   
  26.   }
  27.   if (MouseOpt != NoMouse) {
  28.      // Setup mouse according to graphics mode used 
  29.      if (getmaxx() == 320) Mouse.Setup(LowResGr);
  30.      else if (GDriver == HERCMONOHI) Mouse.Setup(HerculesGr);
  31.      else Mouse.Setup(Graphics);
  32.      if ((!Mouse.SetupOK()) && (MouseOpt == MouseRequired)) {
  33.      closegraph();
  34.      printf("Unable to initialize mouse.");
  35.      exit(1);
  36.      }
  37.   }
  38.   settextstyle(Font,HORIZ_DIR,4);
  39.   FullScrn = new Wso(0x00, 0x00, MonoColors);
  40.   FullScrn->SetSize(getmaxx(),getmaxy());
  41.   StartMsg = NullMsg;
  42. }
  43.  
  44. void MainEventLoop(void)
  45. // Starts up the main event loop by calling the FullScrn object's
  46. // EventLoop method. But first, set the focus to the top Iso. 
  47. {
  48.   if (FullScrn->SubMgr->Top != NULL)
  49.      FullScrn->SubMgr->Top->SwitchFocus(StartMsg);
  50.   FullScrn->SubMgr->EventLoop(StartMsg);
  51. }
  52.  
  53. void CleanUp(void)
  54. // Restore screen to its default mode and turn off the mouse 
  55. {
  56.   delete FullScrn;
  57.   Mouse.TurnOff();
  58.   closegraph();
  59. }
  60.  
  61.